using Engine;
using Game;
using GameEntitySystem;

namespace SCIENEW {
    public class LiquidPumpDevice : SixDirectionalDevice, IEntityDevice<ComponentLiquidPump>, IElectricElementDevice, IFluidTransferrerDevice {
        public LiquidPumpDevice() : base( "LiquidPumpDevice", 203, backSlot: 204) { }
        public string GetEntityName(int value) => "LiquidPump";

        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult) {
            return new BlockPlacementData  { Value = DevicesBlockManager.GetDeviceValue(Id, DevicesUtils.GetDirectionXYZ(componentMiner, true)), CellFace = raycastResult.CellFace };
        }

        public Widget GetWidget(IInventory inventory, ComponentLiquidPump component) => new LiquidPumpWidget(inventory, component);

        public override DeviceBehavior[] GetBehaviors(Project project) => [new LiquidPumpDeviceBehavior(project), new FluidTransferrerDeviceBehavior(project)];

        public ElectricElement CreateElectricElement(SubsystemElectricity subsystemElectricity, int value, int x, int y, int z) => new LiquidPumpElectricElement(subsystemElectricity, new Point3(x, y, z));

        public ElectricConnectorType? GetConnectorType(SubsystemTerrain terrain, int value, int face, int connectorFace, int x, int y, int z) => ElectricConnectorType.Input;

        public int GetConnectionMask(int value) => int.MaxValue;

        public FluidConnector? GetConnector(SubsystemTerrain terrain, int value, int face, int x, int y, int z) => DevicesUtils.GetInnerData(value) == CellFace.OppositeFace(face) ? new FluidConnector(new CellFace(x, y, z, face), FluidConnectorType.Output, 16) : null;//后端材质输出口

        public FluidTransferrer? CreateFluidTransferrer(SubsystemFluidTransfer subsystemFluidTransfer, SubsystemTerrain subsystemTerrain, int value, Point3 point) => new LiquidPumpTransferrer(point, subsystemTerrain);
    }
}